let ransomNote = "a", magazine = "b";
var canConstruct = function (ransomNote, magazine) {
    if (magazine.length < ransomNote.length) {
        return false;
    }
    const ra = new Map();
    const ma = new Map();

    // 统计 ransomNote 中每个字符的出现次数
    for (let char of ransomNote) {
        if (ra.has(char)) {
            ra.set(char, ra.get(char) + 1);
        } else {
            ra.set(char, 1);
        }
    }

    // 统计 magazine 中每个字符的出现次数
    for (let char of magazine) {
        if (ma.has(char)) {
            ma.set(char, ma.get(char) + 1);
        } else {
            ma.set(char, 1);
        }
    }

    // 检查 ransomNote 中的字符是否都能在 magazine 中找到足够的数量
    for (let [key, value] of ra) {
        if (!ma.has(key) || ma.get(key) < value) {
            return false;
        }
    }

    return true;
};

console.log(canConstruct(ransomNote, magazine));